<template>
  <div v-if="!!(data1 || data2 || data3)" class="total-container">
    <div class="chart-title">{{ data1[0].lb }}</div>
    <div class="flex-container">
      <div class="item-box" v-for="item in data1" :key="item.name">
        <img class="icon" :src="item.iconPath" alt="" />
        <div class="right-container">
          <div class="title">{{ item.xm }}</div>
          <div class="bottom-value">
            <div class="num">
              <CountTo
                :startVal="0"
                :endVal="+item.sz"
                :duration="1200"
                separator=""
              ></CountTo>
            </div>
            <div class="unit">{{ item.unit }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="chart-title">{{ data2[0].lb }}</div>
    <div class="flex-container">
      <div class="item-box" v-for="item in data2" :key="item.name">
        <img class="icon" :src="item.iconPath" alt="" />
        <div class="right-container">
          <div class="title">{{ item.xm }}</div>
          <div class="bottom-value">
            <div class="num">
              <CountTo
                :startVal="0"
                :endVal="+item.sz"
                :duration="1200"
                separator=""
              ></CountTo>
            </div>
            <div class="unit">{{ item.unit }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="chart-title">{{ data3[0].lb }}</div>
    <div class="flex-container">
      <div class="item-box" v-for="item in data3" :key="item.name">
        <img class="icon" :src="item.iconPath" alt="" />
        <div class="right-container">
          <div class="title">{{ item.xm }}</div>
          <div class="bottom-value">
            <div class="num">
              <CountTo
                :startVal="0"
                :endVal="+item.sz"
                :duration="1200"
                separator=""
              ></CountTo>
            </div>
            <div class="unit">{{ item.unit }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import icon1 from '../../img/right-row2-icon1.png'
import icon2 from '../../img/right-row2-icon2.png'
import icon3 from '../../img/right-row2-icon3.png'
import icon4 from '../../img/right-row2-icon4.png'
import { getLbData } from '@/api/cultureTuorism.js'
import CountTo from 'vue-count-to'
export default {
  data() {
    return {
      data1: null,
      data2: null,
      data3: null,
      icon1,
      icon2,
      icon3,
      icon4
    }
  },
  components: {
    CountTo
  },
  mounted() {
    this.getData()
  },
  methods: {
    async getData() {
      const [res1, res2, res3] = await Promise.all([
        getLbData('全市文化概况'),
        getLbData('非物质文化遗产代表性项目数量'),
        getLbData('非物质文化遗产代表性传承人')
      ])
      this.data1 = res1.result
      this.data2 = res2.result
      this.data3 = res3.result
      this.data1[0].iconPath = icon1
      this.data1[1].iconPath = icon2
      this.data2[0].iconPath = icon3
      this.data2[1].iconPath = icon4
      this.data3[0].iconPath = icon3
      this.data3[1].iconPath = icon4
    }
  }
}
</script>
<style lang="scss" scoped>
.total-container {
  height: 86%;
  overflow-y: scroll;
  .chart-title {
    width: 420px;
    height: 31px;
    margin-bottom: 16px;
    background: url('../../img/right-row1-icon1.png') no-repeat center center;
    background-size: 100% 100%;
    display: flex;
    justify-content: start;
    align-items: center;
    padding-left: 15px;
    font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
    font-weight: bold;
    font-size: 16px;
    color: #ffffff;
    line-height: 16px;
    text-align: left;
    font-style: normal;
    text-transform: none;
  }
  .flex-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
  }
  .item-box {
    height: 48px;
    width: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    .icon {
      height: 48px;
      width: 51px;
    }
    .right-container {
      height: 100%;
      .title {
        height: 16px;
        background: url('../../img/left-row3-icon3.png') no-repeat left bottom;
        background-size: 93px 12px;
        font-family: MicrosoftYaHeiUI;
        font-size: 16px;
        color: #ffffff;
        line-height: 16px;
        text-align: left;
        font-style: normal;
        text-transform: none;
        padding-left: 10px;
      }
      .bottom-value {
        display: flex;
        justify-content: start;
        align-items: baseline;
        margin-top: 6px;
        padding-left: 10px;
        .num {
          font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
          font-weight: bold;
          font-size: 20px;
          color: #ffde00;
          line-height: 30px;
          text-align: left;
          font-style: normal;
          text-transform: none;
        }
        .unit {
          margin-left: 3px;
          font-family: MicrosoftYaHeiUI;
          font-size: 14px;
          color: #ffffff;
          line-height: 0px;
          text-align: left;
          font-style: normal;
          text-transform: none;
        }
      }
    }
  }
}
</style>
